<?php

namespace api\jeu\perso;

if (!defined('GAME')) {
    exit;
}

class perso extends basePerso {

    public $id;
    public $mat;
    public $pseudo;
    private $_configArray;

    function __construct($id = null, $mat = null, $pseudo = null, $config = null) {
        parent::__construct();
        $this->id = $id;
        $this->mat = $mat;
        $this->pseudo = $pseudo;

        $this->makePersoFromConfig($config);
    }

    private function makePersoFromConfig($config) {
        $this->_configArray = ($config) ? \api\arrayFromIni($config, __NAMESPACE__) : \api\arrayFromIni(PERSO_SHEET, __NAMESPACE__);

        foreach ($this->_configArray['characteristic'] as $carac => $arrayCarac) {
            switch ($arrayCarac['type']) {
                case 'ticker':
                    $type = Caracteristique\CaracteristiqueFactory::NewTicket();
                    break;
                case 'counter':
                    $type = Caracteristique\CaracteristiqueFactory::NewCounter();
                    break;
                case 'graduate':
                    $type = Caracteristique\CaracteristiqueFactory::NewGraduate();
                    break;
                case 'token':
                    $type = Caracteristique\CaracteristiqueFactory::NewToken();
                    break;
                case 'simple':
                default:
                    $type = Caracteristique\CaracteristiqueFactory::NewSimple();
                    break;
            }

            $this->ajouteCaracteristique($carac, $type);
        }

        // Création des événements

        foreach ($this->_configArray['linkEventCarac'] as $event => $arrayLink) {
            $this->ajouteEvenement($event);
            foreach ($arrayLink as $status => $carac) {
                $this->lierEvenementCaracteristique($event, $carac, $status);
            }
        }


        // Liaison Evenemment-Action

        foreach ($this->_configArray['linkEventAction'] as $event => $arrayAction) {
            foreach ($arrayAction as $action) {
                $actionName = '\api\jeu\gameplay\actions\\' . $action;
                $this->lierEvenementAction($event, new $actionName());
            }
        }
    }

    function load() {
        
    }

    function place() {
        
    }

    function move() {
        
    }

    function death() {
        
    }

    function activate() {
        
    }
}

?>